<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
    <title>发帖</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script>
    <script>
        function tj() {
            var m_id = getUrlParam('mid');
            var context = editor.$txt.html();
            var title = $("#title").val();
            //alert(m_id+context+title);
            $.ajax({
                url: "/forum/index.php/thread/post/post",
                type: 'POST',
                data: {"context": context, "title": title, "m_id": m_id},
                dataType: 'json',
                success: function (data, textStatus, jqXHR) {
                    alert(data);
                    window.history.go(-1);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert("Ajax错误！" + jqXHR.status);
                }
            });
        }
        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null)
                return unescape(r[2]);
            return null; //返回参数值
        }
    </script>
</head>
<body>
<table border="1" width="60%" cellspacing="0" align="center">
    <tr style="height: 30px">
        <td width="20%">标题：</td>
        <td width="80%"><input name="title" id="title" style="width: 500px"></td>
    </tr>
    <tr>
        <td>内容：</td>
        <td>
            <div>
                <div id="wangEdit" style="height: 500px;max-height: 800px">
                </div>
            </div>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <button onclick="tj()">提交</button>
        </td>

    </tr>
</table>

<script src="/forum/public/static/vendor/wangEditor/dist/js/wangEditor.min.js"></script>
<link rel="stylesheet" href="/forum/public/static/vendor/wangEditor/dist/css/wangEditor.min.css">
<script type="text/javascript">
    var editor = new wangEditor('wangEdit');
    editor.create();
</script>
</body>
</html>
